<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>${requestScope.loginCustomer.customerName}的个人中心</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/personCenter.css">
</head>
<body>
<jsp:include page="../public/header.jsp"/>

<div class="main">
    <ul class="leftLabel">
        <li>
            <a class="${requestScope.type=="basic"?"selected":""}"
               href="${pageContext.request.contextPath}/center/${requestScope.id}/basic">基本资料</a>
        </li>
        <li>
            <a class="${requestScope.type=="dynamic"?"selected":""}"
               href="${pageContext.request.contextPath}/center/${requestScope.id}/dynamic">动态</a>
        </li>
        <li>
            <a class="${requestScope.type=="choice"?"selected":""}"
               href="${pageContext.request.contextPath}/center/${requestScope.id}/choice">刷题</a>
        </li>
        <li>
            <a class="${requestScope.type=="program"?"selected":""}"
               href="${pageContext.request.contextPath}/center/${requestScope.id}/program">在线编程</a>
        </li>
        <li>
            <a class="${requestScope.type=="contest"?"selected":""}"
               href="${pageContext.request.contextPath}/center/${requestScope.id}/contest">竞赛</a>
        </li>
        <li>
            <a class="${requestScope.type=="message"?"selected":""}"
               href="${pageContext.request.contextPath}/center/${requestScope.id}/message">我的消息</a>
        </li>
    </ul>
    <div class="rightContent">
        <c:if test="${requestScope.type == 'basic'}">
            <div class="menuBox">
                <ul>
                    <li>
                        <a class="selected">基本资料</a>
                    </li>
                </ul>
            </div>
            <c:if test="${requestScope.value == 1}">
                <div class="spanBox">
                    <c:choose>
                        <c:when test="${sessionScope.loginCustomer!=null && sessionScope.loginCustomer.customerId==requestScope.loginCustomer.customerId}">
                            <form class="fl headImages"
                                  action="${pageContext.request.contextPath}/customer/modifyHeadImg"
                                  method="post" enctype="multipart/form-data">
                                <label>
                                    <input type="hidden" name="id" value="${requestScope.loginCustomer.customerId}">
                                    <input type="file" accept="image/*" name="file"
                                           onchange="this.parentElement.parentElement.submit();">
                                    <c:if test="${requestScope.loginCustomer.customerHeadImg == null}">
                                        <img src="${pageContext.request.contextPath}/images/wjb/defaultUserImg.png"
                                             alt="修改头像">
                                    </c:if>
                                    <c:if test="${requestScope.loginCustomer.customerHeadImg != null}">
                                        <img src="${requestScope.loginCustomer.customerHeadImg}" alt="修改头像">
                                    </c:if>
                                </label>
                            </form>
                        </c:when>
                        <c:otherwise>
                            <div class="fl headImages">
                                <c:if test="${requestScope.loginCustomer.customerHeadImg == null}">
                                    <img src="${pageContext.request.contextPath}/images/wjb/defaultUserImg.png"
                                         alt="修改头像">
                                </c:if>
                                <c:if test="${requestScope.loginCustomer.customerHeadImg != null}">
                                    <img src="${requestScope.loginCustomer.customerHeadImg}" alt="修改头像">
                                </c:if>
                            </div>
                        </c:otherwise>
                    </c:choose>
                    <div class="content fr">
                        <c:if test="${sessionScope.loginCustomer!=null && sessionScope.loginCustomer.customerId==requestScope.loginCustomer.customerId}">
                            <div class="spanBox">
                                <a class="btn yes fr"
                                   href="${pageContext.request.contextPath}/center/${requestScope.id}/basic/edit">修改信息</a>
                            </div>
                        </c:if>
                        <table cellspacing="10">
                            <tr>
                                <td>用户名</td>
                                <td>
                                    <span>${requestScope.loginCustomer.customerName}</span>
                                </td>
                            </tr>
                            <tr>
                                <td>手机号</td>
                                <td>
                                    <c:if test="${requestScope.loginCustomer.customerTel == null
                                            ||requestScope.loginCustomer.customerTel == ''}">
                                        <span>未设置</span>
                                    </c:if>
                                    <c:if test="${requestScope.loginCustomer.customerTel != null}">
                                        <span>${requestScope.loginCustomer.customerTel}</span>
                                    </c:if>
                                </td>
                            </tr>
                            <tr>
                                <td>邮箱</td>
                                <td>
                                    <c:if test="${requestScope.loginCustomer.customerEmail == null
                                            ||requestScope.loginCustomer.customerEmail == ''}">
                                        <span>未设置</span>
                                    </c:if>
                                    <c:if test="${requestScope.loginCustomer.customerEmail != null}">
                                        <span>${requestScope.loginCustomer.customerEmail}</span>
                                    </c:if>
                                </td>
                            </tr>
                            <tr>
                                <td>注册时间</td>
                                <td>
                                <span>
                                    <fmt:formatDate value="${requestScope.loginCustomer.customerRegtime}"
                                                    pattern="yyyy-MM-dd"/>
                                </span>
                                </td>
                            </tr>
                            <tr>
                                <td>积分</td>
                                <td>
                                    <span>${requestScope.loginCustomer.customerMark}</span>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </c:if>
            <c:if test="${requestScope.value == 2}">
                <div class="spanBox">
                    <form action="${pageContext.request.contextPath}/customer/edit" method="post">
                        <table cellspacing="10">
                            <tr>
                                <td>
                                    <label for="customerName">用户名</label>
                                </td>
                                <td></td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <input type="hidden" value="${requestScope.loginCustomer.customerId}"
                                           name="customerId">
                                    <input type="text" value="${requestScope.loginCustomer.customerName}"
                                           name="customerName" id="customerName">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label for="phoneIpt">手机号</label>
                                </td>
                                <td style="text-align: right;">
                                    <span class="redWrongMsg" id="phoneSpan">手机号格式有误，请重新输入</span>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <input type="text" value="${requestScope.loginCustomer.customerTel}"
                                           name="customerTel" id="phoneIpt">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label for="emailIpt">邮箱</label>
                                </td>
                                <td style="text-align: right;">
                                    <span class="redWrongMsg" id="emailSpan">邮箱格式有误，请重新输入</span>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <input type="text" value="${requestScope.loginCustomer.customerEmail}"
                                           name="customerEmail" id="emailIpt">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="text-align: center;">
                                    <input class="btn yes submitBtn" type="submit" value="确认" id="changeSubmit">
                                    <a class="btn cancel"
                                       href="${pageContext.request.contextPath}/center/${requestScope.id}/basic">取消</a>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
                <script src="${pageContext.request.contextPath}/js/personCenterBasic2.js"></script>
            </c:if>
        </c:if>
        <c:if test="${requestScope.type == 'dynamic'}">
            <div class="menuBox">
                <ul>
                    <li>
                        <a class="${requestScope.value == 1?"selected":""}"
                           href="${pageContext.request.contextPath}/center/${requestScope.id}/dynamic">我的动态</a>
                    </li>
                    <li>
                        <a class="${requestScope.value == 2?"selected":""}"
                           href="${pageContext.request.contextPath}/center/${requestScope.id}/dynamic/comment">我的评论</a>
                    </li>
                    <li>
                        <a class="${requestScope.value == 3?"selected":""}"
                           href="${pageContext.request.contextPath}/center/${requestScope.id}/dynamic/praise">我的点赞</a>
                    </li>
                    <li>
                        <a class="${requestScope.value == 4?"selected":""}"
                           href="${pageContext.request.contextPath}/center/${requestScope.id}/dynamic/collect">我的收藏</a>
                    </li>
                </ul>
            </div>
            <c:if test="${requestScope.value == 1}">
                <c:choose>
                    <c:when test="${empty requestScope.dynamicAllVOList}">
                        <div class="cell">
                            <div class="label">
                                暂无数据
                            </div>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <c:forEach var="dynamicAllVO" items="${requestScope.dynamicAllVOList}">
                            <div class="cell">
                                <p class="topic_title">
                                    <a href="${pageContext.request.contextPath}/dynamic/${dynamicAllVO.dynamicId}">${dynamicAllVO.dynamic.dynamicTitle}</a>
                                </p>
                                <div class="label">
                                    <p class="spanBox fl">
                            <span>
                                <fmt:formatDate value="${dynamicAllVO.dynamic.dynamicTime}" pattern="yyyy-MM-dd"/>
                            </span>
                                    </p>
                                    <p class="spanBox fr">
                                        <span class="like">赞 ${dynamicAllVO.like}</span>
                                        <span class="collect">收藏 ${dynamicAllVO.collect}</span>
                                        <span class="answer">回复 ${dynamicAllVO.comment}</span>
                                    </p>
                                </div>
                            </div>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>
            </c:if>
            <c:if test="${requestScope.value == 2}">
                <c:choose>
                    <c:when test="${empty requestScope.dynamicCommentVOList}">
                        <div class="cell">
                            <div class="label">
                                暂无数据
                            </div>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <c:forEach var="dynamicCommentVO" items="${requestScope.dynamicCommentVOList}">
                            <div class="cell">
                                <p class="topic_title">
                                    回复了
                                    <a href="${pageContext.request.contextPath}/dynamic/${dynamicCommentVO.dynamicComment.dynamicId}">
                                            ${dynamicCommentVO.dynamic.dynamicTitle}
                                    </a> :
                                </p>
                                <p class="topic_title">
                                        ${dynamicCommentVO.dynamicComment.customerCommentContent}
                                </p>
                                <div class="label">
                                    <p class="spanBox fl">
                                <span>
                                    <fmt:formatDate value="${dynamicCommentVO.dynamicComment.customerCommentTime}"
                                                    pattern="yyyy-MM-dd"/>
                                </span>
                                    </p>
                                </div>
                            </div>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>

            </c:if>
            <c:if test="${requestScope.value == 3}">
                <c:choose>
                    <c:when test="${empty requestScope.dynamicAndPraiseVOList}">
                        <div class="cell">
                            <div class="label">
                                暂无数据
                            </div>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <c:forEach var="dynamicAndPraiseVO" items="${requestScope.dynamicAndPraiseVOList}">
                            <div class="cell">
                                <p class="topic_title">
                                    点赞了
                                    <a href="${pageContext.request.contextPath}/dynamic/${dynamicAndPraiseVO.dynamic.dynamicId}">
                                            ${dynamicAndPraiseVO.dynamic.dynamicTitle}
                                    </a>
                                </p>
                                <div class="label">
                                    <p class="spanBox fl">
                                <span>
                                    <fmt:formatDate value="${dynamicAndPraiseVO.dynamicPraise.praiseTime}"
                                                    pattern="yyyy-MM-dd"/>
                                </span>
                                    </p>
                                </div>
                            </div>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>
            </c:if>
            <c:if test="${requestScope.value == 4}">
                <c:choose>
                    <c:when test="${empty requestScope.dynamicAndCollectVOList}">
                        <div class="cell">
                            <div class="label">
                                暂无数据
                            </div>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <c:forEach var="dynamicAndCollectVO" items="${requestScope.dynamicAndCollectVOList}">
                            <div class="cell">
                                <p class="topic_title">
                                    收藏了：
                                    <a href="${pageContext.request.contextPath}/dynamic/${dynamicAndCollectVO.dynamic.dynamicId}">
                                            ${dynamicAndCollectVO.dynamic.dynamicTitle}
                                    </a>
                                </p>
                                <div class="label">
                                    <p class="spanBox fl">
                                <span>
                                    <fmt:formatDate value="${dynamicAndCollectVO.dynamicCollect.dynamicCollectTime}"
                                                    pattern="yyyy-MM-dd"/>
                                </span>
                                    </p>
                                </div>
                            </div>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>
            </c:if>
        </c:if>

        <c:if test="${requestScope.type == 'choice'}">
            <div class="menuBox">
                <ul>
                    <li>
                        <a class="${requestScope.value == 1?"selected":""}"
                           href="${pageContext.request.contextPath}/center/${requestScope.id}/choice">做过的题目</a>
                    </li>
                    <%--<li>--%>
                        <%--<a class="${requestScope.value == 2?"selected":""}"--%>
                           <%--href="${pageContext.request.contextPath}/center/${requestScope.id}/choice/comment">我的评论</a>--%>
                    <%--</li>--%>
                    <li>
                        <a class="${requestScope.value == 3?"selected":""}"
                           href="${pageContext.request.contextPath}/center/${requestScope.id}/choice/collect">我的收藏</a>
                    </li>
                </ul>
            </div>
            <c:if test="${requestScope.value == 1}">
                <c:choose>
                    <c:when test="${empty requestScope.list}">
                        <div class="cell">
                            <div class="label">
                                暂无数据
                            </div>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <c:forEach var="item" items="${requestScope.list}">
                            <div class="cell">
                                <p class="topic_title">
                            <span>
                                在
                                <fmt:formatDate value="${item.questionSetCreateTime}"
                                                pattern="yyyy-MM-dd"/>
                                参加了
                            </span>
                                    <span>${item.other1}</span>
                                </p>
                                <div class="label">
                                    <p class="spanBox fl">
                                <span>分数: 
                                    <c:choose>
                                        <c:when test="${empty item.questionSetMark}">未完成</c:when>
                                        <c:otherwise>
                                            <fmt:formatNumber maxFractionDigits="0"
                                            value="${item.questionSetMark}"/>
                                        </c:otherwise>
                                    </c:choose>
                                </span>
                                <span>用时:
                                    <c:choose>
                                        <c:when test="${empty item.questionSetThroughTime}">未完成</c:when>
                                        <c:otherwise>
                                            <fmt:formatNumber maxFractionDigits="0"
                                            value="${item.questionSetThroughTime/1000/60}"/>分钟
                                        </c:otherwise>
                                    </c:choose>
                                </span>
                                    </p>
                                </div>
                            </div>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>
            </c:if>
            <c:if test="${requestScope.value == 2}">
                <div class="cell">
                    <p class="topic_title">
                        回复
                        <a href="${pageContext.request.contextPath}/dynamic/${dynamicAllVO.dynamic.dynamicId}">${dynamicAllVO.dynamic.dynamicTitle}</a>
                        : ${dynamicAllVO.dynamic.dynamicContent}
                    </p>
                    <div class="label">
                        <p class="spanBox">
                    <span>
                        2020-02-02
                        <fmt:formatDate value="${dynamicAllVO.dynamic.dynamicTime}" pattern="yyyy-MM-dd"/>
                    </span>
                        </p>
                    </div>
                </div>
            </c:if>
            <c:if test="${requestScope.value == 3}">
                <c:choose>
                    <c:when test="${empty requestScope.choiceAndCollectVOList}">
                        <div class="cell">
                            <div class="label">
                                暂无数据
                            </div>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <c:forEach var="choiceAndCollectVO" items="${requestScope.choiceAndCollectVOList}">
                            <div class="cell">
                                <p class="topic_title">
                                    收藏了：<span>${choiceAndCollectVO.choice.choiceName}</span>
                                </p>
                                <div class="label">
                                    <p class="spanBox fl">
                                        <span>
                                            <fmt:formatDate value="${choiceAndCollectVO.choiceCollect.choiceCollectTime}"
                                                            pattern="yyyy-MM-dd"/>
                                        </span>
                                    </p>
                                </div>
                            </div>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>
            </c:if>
        </c:if>
        <c:if test="${requestScope.type == 'program'}">
            <div class="menuBox">
                <ul>
                    <li>
                        <a class="${requestScope.value == 1?"selected":""}"
                           href="${pageContext.request.contextPath}/center/${requestScope.id}/program">做过的题目</a>
                    </li>
                    <%--<li>--%>
                        <%--<a class="${requestScope.value == 2?"selected":""}"--%>
                           <%--href="${pageContext.request.contextPath}/center/${requestScope.id}/program/comment">我的评论</a>--%>
                    <%--</li>--%>
                    <li>
                        <a class="${requestScope.value == 3?"selected":""}"
                           href="${pageContext.request.contextPath}/center/${requestScope.id}/program/collect">我的收藏</a>
                    </li>
                </ul>
            </div>
            <c:if test="${requestScope.value == 1}">
                <c:choose>
                    <c:when test="${empty requestScope.programRecordVOList}">
                        <div class="cell">
                            <div class="label">
                                暂无数据
                            </div>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <c:forEach var="programRecordVO" items="${requestScope.programRecordVOList}">
                            <div class="cell">
                                <p class="topic_title">
                                    题目名称:
                                    <span>${programRecordVO.program.programTitle}</span>
                                </p>
                                <div class="label">
                                    <p class="spanBox fl">
                                    <span>
                                        <fmt:formatDate value="${programRecordVO.programRecord.programStartTime}" pattern="yyyy-MM-dd"/>
                                    </span>
                                    </p>
                                    <p class="spanBox fr">
                                        <span>${programRecordVO.programRecord.programRecordExecuteTime} ms</span>
                                        <span>${programRecordVO.programRecord.programRecordMemory} M</span>
                                        <span>${programRecordVO.programRecord.programRecordResult==0?"正确":"错误"}</span>
                                    </p>
                                </div>
                            </div>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>
            </c:if>
            <c:if test="${requestScope.value == 2}">
                <div class="cell">
                    <p class="topic_title">
                        回复
                        <a href="${pageContext.request.contextPath}/dynamic/${dynamicAllVO.dynamic.dynamicId}">${dynamicAllVO.dynamic.dynamicTitle}</a>
                        : ${dynamicAllVO.dynamic.dynamicContent}
                    </p>
                    <div class="label">
                        <p class="spanBox">
                    <span>
                        2020-02-02
                        <fmt:formatDate value="${dynamicAllVO.dynamic.dynamicTime}" pattern="yyyy-MM-dd"/>
                    </span>
                        </p>
                    </div>
                </div>
            </c:if>
            <c:if test="${requestScope.value == 3}">
                <c:choose>
                    <c:when test="${empty requestScope.programAndCollectVOList}">
                        <div class="cell">
                            <div class="label">
                                暂无数据
                            </div>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <c:forEach var="programAndCollectVO" items="${requestScope.programAndCollectVOList}">
                            <div class="cell">
                                <p class="topic_title">
                                    收藏了：<span>${programAndCollectVO.program.programTitle}</span>
                                </p>
                                <div class="label">
                                    <p class="spanBox fl">
                                        <span>
                                            <fmt:formatDate value="${programAndCollectVO.programCollect.programCollectTime}"
                                                            pattern="yyyy-MM-dd"/>
                                        </span>
                                    </p>
                                </div>
                            </div>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>
            </c:if>
        </c:if>
        <c:if test="${requestScope.type == 'contest'}">
            <div class="menuBox">
                <ul>
                    <li>
                        <a class="selected">参加过的竞赛</a>
                    </li>
                </ul>
            </div>
            <c:if test="${requestScope.value == 1}">
                <c:choose>
                    <c:when test="${empty requestScope.contestAndMessageVOList}">
                        <div class="cell">
                            <div class="label">
                                暂无数据
                            </div>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <c:forEach var="contestAndMessageVO" items="${requestScope.contestAndMessageVOList}">
                            <div class="cell">
                                <p class="topic_title">
                            <span>
                                在
                                <fmt:formatDate value="${contestAndMessageVO.contestMessage.contestMsgStartTime}"
                                                pattern="yyyy-MM-dd"/>
                                参加了
                            </span>
                                    <span>${contestAndMessageVO.contest.contestName}</span>
                                </p>
                                <div class="label">
                                    <p class="spanBox fl">
                                <span>分数: <fmt:formatNumber maxFractionDigits="0"
                                                            value="${contestAndMessageVO.contestMessage.contestMsgMark}"/></span>
                                        <span>用时:
                                    <fmt:formatNumber
                                            value="${contestAndMessageVO.contestMessage.contestMsgThroughTime/1000/60}"/>
                                    分钟
                                </span>
                                    </p>
                                </div>
                            </div>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>
            </c:if>
        </c:if>
        <c:if test="${requestScope.type == 'message'}">
            <div class="menuBox">
                <ul>
                    <li>
                        <a class="selected">我的消息</a>
                    </li>
                </ul>
            </div>
            <c:if test="${requestScope.value == 1}">
                <c:choose>
                    <c:when test="${empty requestScope.messageList}">
                        <div class="cell">
                            <div class="label">
                                暂无通知
                            </div>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <c:if test="${sessionScope.loginCustomer!=null && sessionScope.loginCustomer.customerId==requestScope.loginCustomer.customerId}">
                            <div class="cell">
                                <a href="${pageContext.request.contextPath}/center/${requestScope.id}/messageCheckAll">全部标为已读</a>
                            </div>
                        </c:if>
                        <c:forEach var="message" items="${requestScope.messageList}">
                            <div class="cell">
                                <p class="topic_title">
                                        ${message.messageType==1 ? "用户消息" : "系统消息"}:&nbsp;&nbsp;&nbsp;${message.messageContent}
                                </p>
                                <div class="label">
                                    <p class="spanBox fl">
                                        <span><fmt:formatDate value="${message.messageTime}" pattern="yyyy-MM-dd"/></span>
                                        <span>${message.status == 0 ? "已读" : "未读"}</span>
                                    </p>
                                    <p class="spanBox fr">
                                        <span>
                                            <a href="javascript:void 0;" onclick="delMsg(this,'${message.messageId}')">删除</a>
                                        </span>
                                    </p>
                                </div>
                            </div>
                        </c:forEach>
                        <script src="${pageContext.request.contextPath}/js/personCenterMessage.js"></script>
                    </c:otherwise>
                </c:choose>
            </c:if>
        </c:if>
    </div>
</div>

<jsp:include page="../public/footer.jsp"/>

</body>
</html>
